package com.example.home.adapter

import androidx.databinding.BindingAdapter
import com.example.home.adapter.provider.BannerViewHolder
import com.zhpan.bannerview.BannerViewPager
import com.zhpan.bannerview.constants.PageStyle

object BannerBindingAdapter {

    @JvmStatic
    @BindingAdapter("initBannerImg")
    fun initBannerImage(bannerViewPager: BannerViewPager<String,BannerViewHolder>, list : List<String>?){

        //创建ViewHolder
        bannerViewPager.setHolderCreator{BannerViewHolder()}
        //样式
        bannerViewPager.setPageStyle(PageStyle.MULTI_PAGE_OVERLAP)

        //接口中没有Banner数据，本地模拟数据
        var locList = arrayListOf(
            "http://ali-img.kaiyanapp.com/fdefdb34cbe3d2ac9964d306febe9025.jpeg?imageMogr2/quality/100",
            "http://ali-img.kaiyanapp.com/945fa937f0955b31224314a4eeef59b8.jpeg?imageMogr2/quality/100",
            "http://ali-img.kaiyanapp.com/f061ac06b3f8e6d913c170d53e1e9303.jpeg?imageMogr2/quality/60/format/jpg",
            "http://ali-img.kaiyanapp.com/c053a3936897e0224b0c553142db8d56.jpeg?imageMogr2/quality/60/format/jpg",
        )

        bannerViewPager.create(list?:locList)

    }
}